package com.example.forjava.util;

public class GenericJsonResult<T> {
    public static final String SUCCESS_CODE = "0000";
    public static final String SUCCESS_MESSAGE = "success";
    private String code;

    private String message;

    private T content;

    public GenericJsonResult() {
        this.code = SUCCESS_CODE;
        this.message = SUCCESS_MESSAGE;
    }

    public GenericJsonResult(T content) {
        this.content = content;
        this.code = SUCCESS_CODE;
    }

    public GenericJsonResult(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public static GenericJsonResult success() {
        return new GenericJsonResult<>();
    }

    public static <T> GenericJsonResult<T> success(T content) {
        return new GenericJsonResult<>(content);
    }

    public static GenericJsonResult fail(String code, String message) {
        return new GenericJsonResult(code, message);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getContent() {
        return content;
    }

    public void setContent(T content) {
        this.content = content;
    }
}
